﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Campus.Main.Basic.InsertValues;
using cpmntctrl;
using dbcntn;

namespace Campus.Main.Basic.Settings
{
    public partial class OdulForm : DefaultForm
    {
        public OdulForm():base()
        {
            InitializeComponent();
            aToDb=new ConnectionToDb(Helper.ConnectionString);
        }

        public override void Initialize()
        {
            aToDb.AddItemDBGridView(dataGridView1,Query.Odul);
            ControlComponent.UnVisibleCells(dataGridView1,0);
        }

        public override void Bind(object sender, FormClosedEventArgs e)
        {
            Initialize();
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            data.Clear();
            ControlComponent.AddToList(data,dataGridView1,e,0,1);
            Odul f=new Odul(data);
            f.FormClosed += Bind;
            f.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length>0)
            {
                aToDb.InsertIntoTable("odul","description",textBox1.Text);
                textBox1.Clear();
                Initialize();
            }
            else
            {
                MessageBox.Show("Талаадарды толтургула!!!");
            }
        }

        private void OdulForm_Load(object sender, EventArgs e)
        {
            Initialize();
        }
    }
}
